<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.pagination.js"></script>
	<link rel="stylesheet" type="text/css" href="css/pagination.css">
<style type="text/css">
 img{
	width:50px;
	height:50px;
}
</style>
</head>
<body>
	
	<c:if test="${user == null }">
		<script type="text/javascript">
			location = "login.html";
		</script>
	</c:if>
	
	<center>
		<h1>欢迎用户:
		<img alt="" src="http://localhost:8080/userimg/${user.icon }">
		${user.name }</h1>
		
		<table>
			<tr>
				<th>编号</th>
				<th>姓名</th>
				<th>头像</th>
				<th>性别</th>
				<th>用户名</th>
				<th>生日</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${userList }" var="u">
				<tr>
					<td>${u.id }</td>
					<td>${u.name }</td>
					<td>
						<img alt="" src="http://localhost:8080/userimg/${u.icon }">
					</td>
					<td>${u.gender }</td>
					<td>${u.userName }</td>
					<td>${u.birthday }</td>
					<td>
						<a href="UserServlet?method=update&id=${u.id }">修改</a>
						<a href="UserServlet?method=delete&id=${u.id }">删除</a>
					</td>
				</tr>
				
			</c:forEach>
			<tr>
				<td colspan="7">
					<div id="user" class="m-style"></div>
				</td>
			</tr>
		</table>
		
	</center>
	<script type="text/javascript">
	$("#user").pagination({
		pageCount:"${pageCount}",
		current:"${pageIndex}",
		mode: 'fixed',
		prevContent:"上页",
		nextContent:"下页",
		homePage:"首页",
		endPage:"尾页",
		coping:true,
		callback:function(api){
			var index = api.getCurrent();
			location.href="UsersServlet?index="+index;	
		}
	});
	
	</script>
	
</body>
</html>